package com.dmall.jdbc.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;

public class TestDao {

	public int insertTest(Connection conn, com.dmall.jdbc.bean.Test test) throws Exception {
		PreparedStatement ps = null;
		try {
			String sql = "insert into test(pro_id, name, birth, gender, introduction) values(?,?,?,?,?)";
			ps = conn.prepareStatement(sql);
			ps.setLong(1, test.getProId());
			ps.setString(2, test.getName());
			ps.setString(3, test.getBirth());
			ps.setInt(4, test.getGender());
			ps.setString(5, test.getIntroduction());
			int count = ps.executeUpdate();
			if (count <= 0) {
				throw new Exception();
			}
			return count;
		} catch (Exception e) {
			throw e;
		} finally {
			if (ps != null) {
				ps.close();
			}
		}
	}
}
